package org.wyn.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.wyn.common.ResultType;
import org.wyn.mongodb.bean.FreshThing;
import org.wyn.mongodb.bean.UserDetail;
import org.wyn.mongodb.dao.impl.UserDetailDao;
import org.wyn.service.IFreshThingService;

import com.google.inject.Inject;

/**
 * 新鲜事action
 * @author wyn
 *
 */
@Namespace("/freshThings")
@ParentPackage("security")
public class FreshThingsAction extends WynActionSupport{

	/**
	 * 进入新鲜事页面
	 * @return
	 */
	@Action(value="goFreshThings",results = {@Result(name = SUCCESS, type = ResultType.FREEMARKER, location = "fresh_things.ftl")})
	public String goFreshThings(){
		String userName = getLoginUserName();
		freshThingList = iFreshThingService.findThingOfFrindAndSelf(userName);
		ud = userDetailDao.findOne("userName",userName);
		return SUCCESS;
	}
	@Inject
	private IFreshThingService iFreshThingService;
	@Inject
	private UserDetailDao userDetailDao;
	private List<FreshThing> freshThingList;
	private UserDetail ud;
	private static final long serialVersionUID = 1L;
	public IFreshThingService getiFreshThingService() {
		return iFreshThingService;
	}
	public void setiFreshThingService(IFreshThingService iFreshThingService) {
		this.iFreshThingService = iFreshThingService;
	}
	public List<FreshThing> getFreshThingList() {
		return freshThingList;
	}
	public void setFreshThingList(List<FreshThing> freshThingList) {
		this.freshThingList = freshThingList;
	}
	public UserDetailDao getUserDetailDao() {
		return userDetailDao;
	}
	public void setUserDetailDao(UserDetailDao userDetailDao) {
		this.userDetailDao = userDetailDao;
	}
	public UserDetail getUd() {
		return ud;
	}
	public void setUd(UserDetail ud) {
		this.ud = ud;
	}

}
